/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ticketManager.model;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;

/**
 *
 * @author luchenyuxx
 */
@Entity
public class Problem {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Long id;
    String title;
    String description;
    String solvement;
    @ManyToOne
    Product productinvolve;
    Integer priority;
    @Temporal(javax.persistence.TemporalType.DATE)
    Date dateOfCreation;
    @Temporal(javax.persistence.TemporalType.DATE)
    Date dateSolved;
    ProblemStates state;
    @ManyToOne
    ManagerUser creator;
    @ManyToOne
    ManagerUser assigner;
    @ManyToOne
    ManagerUser solver;

    public Problem() {
    }

    public Problem(String title, String description, Integer priority) {
        this.title = title;
        this.description = description;
        this.priority = priority;
        state = ProblemStates.NewlyCreated;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getSolvement() {
        return solvement;
    }

    public void setSolvement(String solvement) {
        this.solvement = solvement;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getDateSolved() {
        return dateSolved;
    }

    public void setDateSolved(Date dateSolved) {
        this.dateSolved = dateSolved;
    }

    public ProblemStates getState() {
        return state;
    }

    public void setState(ProblemStates state) {
        this.state = state;
    }

    public Product getProductinvolve() {
        return productinvolve;
    }

    public void setProductinvolve(Product productinvolve) {
        this.productinvolve = productinvolve;
    }

    public ManagerUser getCreator() {
        return creator;
    }

    public void setCreator(ManagerUser creator) {
//        if(creator.problemsCreated.contains(this)){
        this.creator = creator;
//        }else{
//            creator.createProblem(this);
//        }
    }

    public ManagerUser getAssigner() {
        return assigner;
    }

    public void setAssigner(ManagerUser assigner) {
        this.assigner = assigner;
    }

    public ManagerUser getSolver() {
        return solver;
    }

    public void setSolver(ManagerUser solver) {
        this.solver = solver;
    }

    public Long getId() {
        return id;
    }

    public Date getDateOfCreation() {
        return dateOfCreation;
    }

    public void setDateOfCreation(Date dateOfCreation) {
        this.dateOfCreation = dateOfCreation;
    }
}
